import { dataserviceAxios, dataQueryAxios, datashopAxios } from '@/utils/request'

// 获取用户列表
export const getAllUserList = (params: any = {}): Promise<any> => {
  return dataserviceAxios({
    url: '/api/datashop/v3/users',
    method: 'get',
    params: {
      page: 1,
      page_size: 10,
      ...params
    }
  }).then((res: any) =>
    res.items.map((item: any) => ({
      label: item.name,
      value: item.id
    }))
  )
}

// 获取关联项目名称
export const getAllProjectOptions = (): Promise<any> => {
  return dataserviceAxios({
    url: `/api/project/v2/projects/project_options`,
    method: 'get',
    params: {
      page: 1,
      page_size: 99999,
      do_page: false
    }
  }).then((res) =>
    res.map((item: any) => ({
      label: item.name,
      value: item.id
    }))
  )
}

// 新-添加项目
export const addNewOrderProject = (data: any) => {
  return dataserviceAxios({
    url: '/api/project/v2/projects',
    method: 'post',
    data
  })
}

//设置用户邮箱

export const change_email = (data: any) => {
  return dataQueryAxios({
    url: '/api/data-query/v1/users/me:change-email',
    method: 'post',
    data
  })
}
//当前用户当天导出条数

export const export_daily_counts = () => {
  return dataQueryAxios({
    url: '/api/data-query/v1/users/me/export-daily-counts',
    method: 'get'
  })
}
//园区列表
export const getParkList = (params?: { keyword?: string; page?: number; page_size?: number }) => {
  return datashopAxios({
    url: '/api/datashop/v3/spec-option/parks',
    method: 'get',
    params
  })
}

// 列表
export const getSettingAtlasList = (params: any): Promise<any> => {
  return dataQueryAxios({
    url: `/api/data-query/v1/release-maps`,
    method: 'get',
    params: {
      release_status: 'published',
      ...params
    }
  })
}
